package com.adobe.crypto
{
	import flash.utils.ByteArray;
	
	/**
	 * Adler32校验算法类
	 *
	 * @Author DuskEye
	 * @langversion 3.0
	 * @productversion 1.0
	 */
	public class Adler32
	{
		/**
		 * 计算Adler32校验值
		 * @param data 数据
		 * @return 校验码
		 */
		public static function hash(data:ByteArray):uint
		{
			var a:uint = 1;
			var b:uint = 0;
			for (var i:int = 0; i < data.length; i++)
			{
				a = (a + data[i]) % 65521;
				b = (b + a) % 65521;
			}
			return (b << 16) | a;
		}
	}
}